/*
 Navicat Premium Dump SQL

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50744 (5.7.44)
 Source Host           : 127.0.0.1:3306
 Source Schema         : smart_community

 Target Server Type    : MySQL
 Target Server Version : 50744 (5.7.44)
 File Encoding         : 65001

 Date: 22/09/2025 10:23:31
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sc_leave
-- ----------------------------
DROP TABLE IF EXISTS `sc_leave`;
CREATE TABLE `sc_leave` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '请假ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `leave_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请假类型：personal-事假，sick-病假，annual-年假，compensatory-调休',
  `start_date` date NOT NULL COMMENT '开始日期',
  `end_date` date NOT NULL COMMENT '结束日期',
  `start_time` time DEFAULT NULL COMMENT '开始时间',
  `end_time` time DEFAULT NULL COMMENT '结束时间',
  `days` decimal(4,1) NOT NULL DEFAULT '0.0' COMMENT '请假天数',
  `reason` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请假原因',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：1-待审批，2-已批准，3-已拒绝，4-已撤销',
  `approver_id` bigint(20) DEFAULT NULL COMMENT '审批人ID',
  `approve_time` datetime DEFAULT NULL COMMENT '审批时间',
  `approve_remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '审批备注',
  `attachment_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '附件URL（如病假证明）- 已废弃，使用attachments字段替代',
  `attachments` text COLLATE utf8mb4_unicode_ci COMMENT '附件信息（JSON格式）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建人ID',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新人ID',
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志：0-未删除，1-已删除',
  `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
  `property_company_id` bigint(20) NOT NULL COMMENT '物业公司ID',
  `remark` text COLLATE utf8mb4_unicode_ci COMMENT '备注',
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_status` (`status`),
  KEY `idx_leave_type` (`leave_type`),
  KEY `idx_approver_id` (`approver_id`),
  KEY `idx_start_date` (`start_date`),
  KEY `idx_create_time` (`create_time`),
  CONSTRAINT `fk_leave_approver` FOREIGN KEY (`approver_id`) REFERENCES `sc_user` (`id`) ON DELETE SET NULL,
  CONSTRAINT `fk_leave_user` FOREIGN KEY (`user_id`) REFERENCES `sc_user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='请假记录表';

-- ----------------------------
-- Records of sc_leave
-- ----------------------------
BEGIN;
INSERT INTO `sc_leave` (`id`, `user_id`, `leave_type`, `start_date`, `end_date`, `start_time`, `end_time`, `days`, `reason`, `status`, `approver_id`, `approve_time`, `approve_remark`, `attachment_url`, `attachments`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `property_company_id`, `remark`) VALUES (2, 46, 'personal', '2025-09-20', '2025-09-27', NULL, NULL, 8.0, 'gaga', 1, NULL, NULL, NULL, NULL, '[{\"id\":74,\"url\":\"http://localhost:9000/smart-community/leave_attachment/20250920213920_9671f4a103da42faaf6f22159b8b1af3.png\",\"fileName\":\"微信图片_2025-09-17_102201_153.png\",\"fileSize\":76014,\"fileType\":\"image/png\",\"fileExtension\":\"png\",\"uploadType\":\"LEAVE_ATTACHMENT\",\"uploadSource\":\"APP\",\"uploading\":false,\"error\":false},{\"id\":67,\"url\":\"http://localhost:9000/smart-community/cleaning_image/20250918221206_50b0a2f0cf2e4739a5554df91b6258e7.png\",\"fileName\":\"微信图片_2025-09-17_102156_962.png\",\"fileSize\":78144,\"fileType\":\"image/png\",\"fileExtension\":\"png\",\"uploadType\":\"CLEANING_IMAGE\",\"uploadSource\":\"APP\",\"uploading\":false,\"error\":false}]', '2025-09-20 21:39:35', '2025-09-20 13:40:31', 46, 46, 0, 0, 1015, NULL);
INSERT INTO `sc_leave` (`id`, `user_id`, `leave_type`, `start_date`, `end_date`, `start_time`, `end_time`, `days`, `reason`, `status`, `approver_id`, `approve_time`, `approve_remark`, `attachment_url`, `attachments`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `property_company_id`, `remark`) VALUES (3, 46, 'sick', '2025-09-20', '2025-09-27', NULL, NULL, 8.0, 'gaga', 1, NULL, NULL, NULL, NULL, '[{\"id\":35,\"url\":\"http://localhost:9000/smart-community/other/20250828142927_67ddc6516dc74fe3b2cce3719a3be2eb.jpg\",\"fileName\":\"008yeksBly1hptp9bjo7ij32gw3pchdv.jpg\",\"fileSize\":3649584,\"fileType\":\"image/jpeg\",\"fileExtension\":\"jpg\",\"uploadType\":\"OTHER\",\"uploadSource\":\"WEB\",\"uploading\":false,\"error\":false},{\"id\":75,\"url\":\"http://localhost:9000/smart-community/leave_attachment/20250920233551_101a291eb0e646cf92d2c412f3c0f4ff.jpg\",\"fileName\":\"008yeksBly1hl67pb9zahj32b734pnpf.jpg\",\"fileSize\":3889051,\"fileType\":\"image/jpeg\",\"fileExtension\":\"jpg\",\"uploadType\":\"LEAVE_ATTACHMENT\",\"uploadSource\":\"APP\",\"uploading\":false,\"error\":false}]', '2025-09-20 23:39:17', '2025-09-20 23:39:17', 46, 46, 0, 0, 1015, NULL);
INSERT INTO `sc_leave` (`id`, `user_id`, `leave_type`, `start_date`, `end_date`, `start_time`, `end_time`, `days`, `reason`, `status`, `approver_id`, `approve_time`, `approve_remark`, `attachment_url`, `attachments`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `property_company_id`, `remark`) VALUES (4, 46, 'sick', '2025-09-22', '2025-09-29', NULL, NULL, 8.0, 'yyyyyyyyy', 1, NULL, NULL, NULL, NULL, '[{\"id\":2,\"url\":\"http://localhost:9000/smart-community/image/20250808144326_1a5aed843a434c369d336ba974504733.png\",\"fileName\":\"萝莉_闭眼.png\",\"fileSize\":968910,\"fileType\":\"image/png\",\"fileExtension\":\"png\",\"uploadType\":\"IMAGE\",\"uploadSource\":\"APP\",\"uploading\":false,\"error\":false},{\"id\":10,\"url\":\"http://localhost:9000/smart-community/house_type_plan/20250814181303_ce9ea78435174284b0915a59001a2a91.jpg\",\"fileName\":\"微信图片_20250411112444.jpg\",\"fileSize\":86213,\"fileType\":\"image/jpeg\",\"fileExtension\":\"jpg\",\"uploadType\":\"HOUSE_TYPE_PLAN\",\"uploadSource\":\"WEB\",\"uploading\":false,\"error\":false}]', '2025-09-22 10:22:09', '2025-09-22 10:22:09', 46, 46, 0, 0, 1015, NULL);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
